<template>
  <div class="item">
    <el-row>
      <el-col :span="24">
        <div class="grid-content bg-purple-dark">
          <el-button type="primary" @click="TJ_TP_shouye = true">+新建</el-button>
          <el-button v-if="arr.length == 0" type="info" plain>-删除</el-button>
          <el-button v-else type="primary" @click="duoxuanshanchu">-删除</el-button>
          <el-button type="primary" @click="geilist">刷新</el-button>
        </div>
      </el-col>
      <el-col :span="24" style="margin-top: 20px;padding-bottom: 20px;">
        <div class="grid-content bg-purple-dark">
          <el-col :span="5" class="sousuo">
            <el-input v-model="input" placeholder="仓库编号或名称" />
          </el-col>
          <el-button type="primary" @click="chaxun">查询</el-button>
          <el-button type="info" plain @click="chongzhi">重置</el-button>
        </div>
      </el-col>
      <el-table ref="multipleTable" border :data="list" tooltip-effect="dark" style="width: 100%" @selection-change="handleSelectionChange">
        <el-table-column type="selection" width="55" />
        <el-table-column prop="Code" label="编号" width="120" />
        <el-table-column prop="Name" label="名称" width="120" />
        <el-table-column prop="Length" label="长" width="120" />
        <el-table-column prop="Width" label="宽" width="120" />
        <el-table-column prop="High" label="高" width="120" />
        <el-table-column prop="IsZone" label="是否有分区" width="120">
          <template slot-scope="scope">{{ scope.row.IsZone == false ?'否' : '是' }}</template>
        </el-table-column>
        <el-table-column prop="" label="操作">
          <template slot-scope="scope">
            <el-button type="text" @click="BianJi(scope.row)">编辑</el-button>
            <el-button type="text" @click="ShanChu(scope.row)">删除</el-button>
            <el-button type="text" @click="FenQue(scope.row)">分区管理</el-button>
            <el-button type="text" @click="WuLiao(scope.row)">关联物料</el-button>
            <el-button type="text" @click="SY_dizhi(scope.row)">关联货位</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-row>
    <!-- 新增托盘类型 -->
    <el-dialog title="新增供应商" :visible.sync="TJ_TP_shouye" width="30%">
      <el-form
        ref="TP_list"
        :model="TP_list"
        :rules="rules"
        label-width="80px"
      >
        <el-col :span="12">
          <el-form-item label="编号:">
            <el-input placeholder="系统自动生成" :disabled="true" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="名称:" prop="Name">
            <el-input v-model="TP_list.Name" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="长:" prop="Type">
            <el-input v-model="TP_list.Length" type="number" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="宽:">
            <el-input v-model="TP_list.Width" type="number" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="高:">
            <el-input v-model="TP_list.High" type="number" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="托盘管理:">
            <el-radio-group v-model="TP_list.IsZone" size="small">
              <el-radio-button label="true">是</el-radio-button>
              <el-radio-button label="false">否</el-radio-button>
            </el-radio-group>
          </el-form-item>
        </el-col>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="QX_XJ_tuopan">取 消</el-button>
        <el-button type="primary" @click="QR_XJ_topan">确 定</el-button>
      </span>
    </el-dialog>
    <!-- 分区管理 -->
    <el-drawer
      title="分区管理"
      :visible.sync="FQ_guanli"
      size="50%"
    >
      <div style="margin-left: 40px;">
        <el-button type="primary" @click="TJ_FQ = true">+新建</el-button>
        <el-button v-if="FQ_arr.length == 0" type="info" plain>-删除</el-button>
        <el-button v-else type="primary" @click="SC_fenqu">-删除</el-button>
        <el-button type="primary" @click="FQ_shuaxin">刷新</el-button>
        <el-table ref="multipleTable" border :data="FQ_list" tooltip-effect="dark" style="width: 100%; margin-top: 20px;" @selection-change="FQ_dizhi">
          <el-table-column type="selection" />
          <el-table-column prop="Code" label="编号" width="100" />
          <el-table-column prop="Name" label="名称" width="100" />
          <el-table-column prop="X" label="X" width="100" />
          <el-table-column prop="Y" label="Y" width="100" />
          <el-table-column prop="IsDefault" label="是否默认" width="100">
            <template slot-scope="scope">{{ scope.row.IsDefault == false ? '否' : '是' }}</template>
          </el-table-column>
          <el-table-column prop="" label="操作">
            <template slot-scope="scope">
              <el-button type="text" @click="FQ_HN_bianji(scope.row)">编辑</el-button>
              <el-button type="text" @click="FQ_HN_shanchu(scope.row)">删除</el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </el-drawer>
    <!-- 新增分区 -->
    <el-dialog title="新增" :visible.sync="TJ_FQ" width="30%">
      <el-form
        ref="TJ_FQ_list"
        :model="TJ_FQ_list"
        :rules="ruless"
        label-width="80px"
      >
        <el-col :span="12">
          <el-form-item label="编号:" prop="Code">
            <el-input v-model="TJ_FQ_list.Code" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="名称:" prop="Name">
            <el-input v-model="TJ_FQ_list.Name" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="X:" prop="Type">
            <el-input v-model="TJ_FQ_list.X" type="number" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="Y:">
            <el-input v-model="TJ_FQ_list.Y" type="number" />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="托盘管理:">
            <el-radio-group v-model="TJ_FQ_list.IsDefault" size="small">
              <el-radio-button label="true">是</el-radio-button>
              <el-radio-button label="false">否</el-radio-button>
            </el-radio-group>
          </el-form-item>
        </el-col>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="QR_XJ_quexiao">取 消</el-button>
        <el-button type="primary" @click="QR_XJ_fenqu">确 定</el-button>
      </span>
    </el-dialog>
    <!-- 关联物料 -->
    <el-drawer
      title="关联物料"
      :visible.sync="GL_wuliao"
      size="50%"
    >
      <div style="margin-left: 40px;">
        <el-button type="primary" @click="XJWL">+新建</el-button>
        <el-button v-if="WL_arr.XZ_id.length == 0" type="info" plain>-删除</el-button>
        <el-button v-else type="primary" @click="shanchuWL">-删除</el-button>
        <el-button type="primary" @click="shuaxinWL">刷新</el-button>
        <el-table ref="multipleTable" border :data="GL_list" tooltip-effect="dark" style="width: 100%; margin-top: 20px;" @selection-change="WLGL_XZ">
          <el-table-column type="selection" />
          <el-table-column prop="PB_Material.Code" label="物料编号" />
          <el-table-column prop="PB_Material.Name" label="物料名称" />
          <el-table-column prop="PB_Material.Spec" label="物料规格" />
          <el-table-column prop="" label="操作">
            <template slot-scope="scope">
              <el-button type="text" @click="GLWL_shanchu(scope.row)">删除</el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </el-drawer>
    <!-- 新建物料管理 -->
    <el-dialog title="新增" :visible.sync="TJ_WL" width="60%">
      <el-form
        ref="TJ_FQ_list"
        :model="TJ_WLGL_SS"
        :rules="ruless"
        label-width="80px"
      >
        <el-col :span="24" style="margin-top: 20px;padding-bottom: 20px;">
          <div class="grid-content bg-purple-dark">
            <el-col :span="4" class="sousuo">
              <el-select ref="selectTree" v-model="TJ_WLGL_SS.TypeId" :value="newValue" placeholder="物料类型">
                <el-option v-for="(item, index) in TJ_WLGL_LeiXing" :key="index" :label="item.Text" :value="item.Id" style="display: none;" />
                <el-tree
                  ref="selecteltree"
                  :data="TJ_WLGL_LeiXing"
                  node-key="TJ_WLGL_LeiXing.Id"
                  highlight-current
                  :props="defaultProps"
                  :current-node-key="TJ_WLGL_LeiXing.value"
                  default-expand-all
                  @node-click="handleNodeClick"
                />
              </el-select>
            </el-col>
            <el-col :span="5" class="sousuo">
              <el-input v-model="TJ_WLGL_SS.Keyword" placeholder="物料名称\编号\条码" />
            </el-col>
            <el-col :span="6" class="sousuo">
              <el-input v-model="TJ_WLGL_SS.ContactName" placeholder="客户\供应商名称或编号" />
            </el-col>
            <el-button type="primary" @click="WLGL_chaxun">查询</el-button>
            <el-button type="info" plain @click="WLGL_chongzhi">重置</el-button>
            <el-table ref="multipleTable" border :data="TJ_GL_list" tooltip-effect="dark" style="width: 100%; margin-top: 20px;" @selection-change="WLGL_XJ_XZ">
              <el-table-column type="selection" />
              <el-table-column prop="Name" label="物料名称" />
              <el-table-column prop="Code" label="物料编号" />
              <el-table-column prop="MaterialType.Name" label="物料类别" />
              <el-table-column prop="BarCode" label="条码" />
              <el-table-column prop="SimpleName" label="物料简介" />
              <el-table-column prop="Spec" label="物料规格" />
            </el-table>
            <p style="margin-left: 800px;">共{{ TJ_GL_list.length }}条数据</p>
          </div>
        </el-col>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="GLWL_XJ_QX">取 消</el-button>
        <el-button type="primary" @click="GLWL_XJ_QD">确 定</el-button>
      </span>
    </el-dialog>
    <!-- 关联货位 -->
    <el-drawer
      title="关联货位"
      :visible.sync="GL_huowei"
      size="50%"
    >
      <div style="margin-left: 40px;">
        <el-button type="primary" @click="XJHW">+新建</el-button>
        <el-button v-if="WL_arr.XZ_id.length == 0" type="info" plain>-删除</el-button>
        <el-button v-else type="primary" @click="shanchuWL">-删除</el-button>
        <el-button type="primary" @click="shuaxinWL">刷新</el-button>
        <el-table ref="multipleTable" border :data="HW_list" tooltip-effect="dark" style="width: 100%; margin-top: 20px;" @selection-change="WLGL_XJ_XZ">
          <el-table-column type="selection" />
          <el-table-column prop="PB_Location.Code" label="货位编号" />
          <el-table-column prop="PB_Location.Name" label="货位名称" />
          <el-table-column prop="PB_Location.PB_StorArea.Name" label="货区" />
          <el-table-column prop="PB_Location.PB_Storage.Name" label="仓库" />
          <el-table-column prop="" label="操作">
            <template slot-scope="scope">
              <el-button type="text" @click="GLWL_shanchu(scope.row)">删除</el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </el-drawer>
    <!-- 添加关联货位 -->
    <el-dialog title="货位选择" :visible.sync="TJ_HW" width="60%">
      <el-form
        ref="TJ_FQ_list"
        :model="TJ_WLGL_SS"
        :rules="ruless"
        label-width="80px"
      >
        <el-col :span="24" style="margin-top: 20px;padding-bottom: 20px;">
          <div class="grid-content bg-purple-dark">
            <el-col :span="4" class="sousuo">
              <el-select ref="selectTree" v-model="GLHW_TJ.TypeId" :value="newValue" placeholder="物料类型">
                <el-option v-for="(item, index) in TJ_HWGL_SOUSUO" :key="index" :label="item.Name" :value="item.Id" />
              </el-select>
            </el-col>
            <el-col :span="5" class="sousuo">
              <el-input v-model="GLHW_TJ.Keyword" placeholder="物料名称\编号\条码" />
            </el-col>
            <el-col :span="6" class="sousuo">
              <el-input v-model="GLHW_TJ.AreaName" placeholder="客户\供应商名称或编号" />
            </el-col>
            <el-button type="primary" @click="GLHW_chaxun">查询</el-button>
            <el-button type="info" plain @click="GLHW_chongzhi">重置</el-button>
            <el-table ref="multipleTable" border :data="TJ_HW_list" tooltip-effect="dark" style="width: 100%; margin-top: 20px;" @selection-change="GLHW_xz">
              <el-table-column type="selection" />
              <el-table-column prop="Code" label="货位编号" />
              <el-table-column prop="Name" label="货位名称" />
              <el-table-column prop="PB_Storage.Name" label="仓库" />
              <el-table-column prop="PB_StorArea.Name" label="货区" />
              <el-table-column prop="PB_Laneway.Name" label="巷道" />
              <el-table-column prop="PB_Rack.Name" label="货架" />
            </el-table>
            <p style="margin-left: 800px;">共{{ TJ_HW_list.length }}条数据</p>
          </div>
        </el-col>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="GLHW_XJ_QX">取 消</el-button>
        <el-button type="primary" @click="GLHW_XJ_QD">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
import { getList, addlist, deletelist, getTPxiangxi, updatelist, addFenQv, deletelistFenQ, getFenQxiangxi, getWuLiaoGuanLian, getWuLiaoXuanZe, getWuLiaoXuanZe2, getChaXun_WLGL, addWLGLlist, deleteGLWLlist, getGLHWlist, getaddGLHWlist, addGLHWlist, GLHW_chaxun, addGLHWlist2 } from '@/api/tuopanleixing'
export default {
  data() {
    return {
      newValue: '',
      Text: '',
      TJ_TP_shouye: false, // 控制新建弹框
      FQ_guanli: false, // 控制分区管理弹框
      TJ_FQ: false, // 控制分区弹框
      XJwuliao: false, // 控制物料弹框
      GL_wuliao: false, // 控制关联管理弹框
      GL_huowei: false, // 控制关联货位弹框
      TJ_WL: false, // 控制物料管理添加弹框
      TJ_HW: false, // 控制关联货位添加弹框
      list: [], // 获取托盘列表
      FQ_list: [], // 获取分区的列表
      GL_list: [], // 获取关联物料列表
      HW_list: [], // 获取关联货位列表
      TJ_HW_list: [], // 获取关联货位添加列表
      TJ_GL_list: [], // 获取关联物料添加下的列表
      TJ_WLGL_xinjianshuku: {}, // 获取关联物料添加的总数居
      TJ_WLGL_LeiXing: [], // 获取关联物料添加下的物料类型
      TJ_HWGL_SOUSUO: [],
      XZ_xjhw_id: {
        id: '',
        keys: []
      },
      TJ_WLGL_SS: { // 物料管理添加下的搜索
        TypeId: '',
        Keyword: '',
        ContactName: ''
      },
      GLHW_TJ: {
        TypeId: '',
        Keyword: '',
        AreaName: ''
      },
      FQ_id: '', // 分区id
      wl_id: { // 添加物料管理
        id: '',
        keys: []
      },
      XJ_WL_list: {},
      TJ_FQ_list: {
        Code: '',
        Name: '',
        X: '',
        Y: '',
        IsDefault: '',
        TrayTypeId: ''
      }, // 获取分区的列表
      defaultProps: {
        children: 'children',
        label: 'Text'
      },
      arr: [], // 被选中的托盘列表
      FQ_arr: [], // 被选中的分区列表
      WL_arr: {
        id: '',
        XZ_id: []
      }, // 被选中的物料列表
      input: '', // 搜索框输入内容
      TP_list: {
        High: '', // 高
        IsZone: '', // 是否
        Length: '', // 长
        Name: '', // 名称
        Width: '' // 宽
        // labelPosition: 'right'
      }, // 新增托盘信息
      rules: {
        Name: [
          { required: true, message: '请输入供应商名称', trigger: 'blur' }
        ]
      },
      ruless: {
        Name: [
          { required: true, message: '请输入编号', trigger: 'blur' }
        ],
        Code: [
          { required: true, message: '请输入名称', trigger: 'blur' }
        ]
      }
    }
  },
  created() {
    this.geilist()
  },
  methods: {
    async geilist() { // 获取托盘列表
      this.list = await getList()
      console.log(this.list)
    },
    handleSelectionChange(val) { // 获取被选中托盘id
      this.multipleSelection = val
      console.log('val', val)
      if (val.length > 0) {
        for (let i = 0; i < val.length; i++) {
          if (val[i].Id !== this.arr[i]) {
            this.arr.push(val[i].Id)
          }
        }
      } else {
        this.arr = val
      }
      console.log('arr', this.arr)
    },
    async chaxun() { // 查询
      this.list = await getList(this.input)
      console.log(this.input)
    },
    chongzhi() { // 重置
      this.input = ''
    },
    QR_XJ_topan() { // 新增托盘管理
      this.$refs.TP_list.validate(async(valid) => {
        if (valid) {
          await addlist(this.TP_list)
          this.geilist()
          this.QX_XJ_tuopan()
        } else {
          console.log('error submit!!')
          return false
        }
      })
    },
    Cz_TP_LIST() { // 重置
      this.TP_list = {
        High: '', // 高
        IsZone: '', // 是否
        Length: '', // 长
        Name: '', // 名称
        Width: '' // 宽
      }
    },
    QX_XJ_tuopan() { // 新增取消
      this.Cz_TP_LIST()
      // this.$refs.TP_list.resetFields()
      this.TJ_TP_shouye = false
    },
    async duoxuanshanchu() { // 批量删除
      this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(async() => {
        await deletelist(this.arr)
        this.geilist()
        this.$message({
          type: 'success',
          message: '删除成功!'
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    },
    async BianJi(row) { // 编辑
      this.TP_list = await getTPxiangxi({ id: row.Id })
      this.TJ_TP_shouye = true
    },
    async ShanChu(row) {
      this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(async() => {
        this.arr.push(row.Id)
        await deletelist(this.arr)
        this.geilist()
        this.$message({
          type: 'success',
          message: '删除成功!'
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    },
    async FenQue(row) { // 分区管理
      this.FQ_id = row.Id
      this.FQ_shuaxin()
      this.FQ_guanli = true
    },
    async FQ_shuaxin() { // 获取分区列表
      this.FQ_list = await updatelist(this.FQ_id)
      console.log(this.FQ_list)
    },
    FQ_dizhi(val) { // 分区多选
      this.multipleSelection = val
      if (val.length > 0) {
        for (let i = 0; i < val.length; i++) {
          if (val[i].Id !== this.FQ_arr[i]) {
            this.FQ_arr.push(val[i].Id)
          }
        }
      } else {
        this.FQ_arr = val
      }
      console.log('FQ_arr', this.FQ_arr)
    },
    async QR_XJ_fenqu() { // 确认添加分区
      this.$refs.TJ_FQ_list.validate(async(valid) => {
        if (valid) {
          this.TJ_FQ_list.TrayTypeId = this.FQ_id
          await addFenQv(this.TJ_FQ_list)
          this.FQ_list = await updatelist(this.FQ_id)
          this.QR_XJ_quexiao()
        } else {
          console.log('error submit!!')
          return false
        }
      })
    },
    QR_XJ_quexiao() { // 取消添加分区
      this.Cz_XZ_fenqu()
      this.TJ_FQ = false
    },
    Cz_XZ_fenqu() { // 重置
      this.TJ_FQ_list = {
        Code: '',
        Name: '',
        X: '',
        Y: '',
        IsDefault: '',
        TrayTypeId: ''
      }
    },
    async SC_fenqu() { // 删除分区
      this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(async() => {
        await deletelistFenQ(this.FQ_arr)
        this.FQ_list = await updatelist(this.FQ_id)
        this.$message({
          type: 'success',
          message: '删除成功!'
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    },
    async FQ_HN_bianji(row) { // 编辑分区
      this.TJ_FQ_list = await getFenQxiangxi({ id: row.Id })
      this.TJ_FQ = true
    },
    async FQ_HN_shanchu(row) { // 行内删除分区
      this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(async() => {
        this.FQ_arr.push(row.Id)
        await deletelistFenQ(this.FQ_arr)
        this.FQ_shuaxin()
        this.$message({
          type: 'success',
          message: '删除成功!'
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    },
    async WuLiao(row) { // 关联物料
      this.wl_id.id = row.Id
      this.GL_list = await getWuLiaoGuanLian(this.wl_id.id)
      this.GL_wuliao = true
    },
    async XJWL() { // 新建物料管理
      this.TJ_GL_list = await getWuLiaoXuanZe()
      this.TJ_WLGL_LeiXing = await getWuLiaoXuanZe2()
      console.log('123132', this.TJ_WLGL_LeiXing)
      this.TJ_WL = true
    },
    handleNodeClick(node) {
      console.log('sadasd', node)
      this.TJ_WLGL_SS.TypeId = node.Text
      this.newvalue = node.Id
      console.log('newValye', this.newvalue)
      this.$refs.selectTree.blur()
    },
    WLGL_XJ_XZ(val) { // 新建物料管理选中
      if (val.length > 0) {
        for (let i = 0; i < val.length; i++) {
          if (val[i].Id !== this.wl_id.keys[i]) {
            this.wl_id.keys.push(val[i].Id)
          }
        }
      } else {
        this.wl_id.keys = val
      }
      console.log('wl_id.keys', this.wl_id.keys)
    },
    WLGL_chongzhi() { // 重置
      this.TJ_WLGL_SS = {
        TypeId: '',
        Keyword: '',
        ContactName: ''
      }
    },
    async WLGL_chaxun() { // 查询
      this.TJ_GL_list = await getChaXun_WLGL(this.TJ_WLGL_SS)
    },
    async shuaxinWL() {
      this.GL_list = await getWuLiaoGuanLian(this.wl_id.id)
    },
    async GLWL_XJ_QX() { // 新建关联物料——取消
      this.shuaxinWL()
      this.WLGL_chongzhi()
      this.TJ_WL = false
    },
    async GLWL_XJ_QD() { // 新建关联物料——确定
      console.log('123')
      await addWLGLlist(this.wl_id)
      this.GLWL_XJ_QX()
    },
    WLGL_XZ(val) { // 关联物料选中
      this.multipleSelection = val
      if (val.length > 0) {
        for (let i = 0; i < val.length; i++) {
          if (val[i].MaterialId !== this.WL_arr.XZ_id[i]) {
            this.WL_arr.XZ_id.push(val[i].MaterialId)
          }
        }
      } else {
        this.WL_arr.XZ_id = val
      }
      console.log('WL_arr', this.WL_arr.XZ_id)
      console.log('val', val)
    },
    async shanchuWL() { // 物料关联多选删除
      this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(async() => {
        await deleteGLWLlist(this.WL_arr)
        this.shuaxinWL()
        this.$message({
          type: 'success',
          message: '删除成功!'
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    },
    async GLWL_shanchu(row) {
      this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(async() => {
        this.WL_arr.id = this.wl_id.id
        this.WL_arr.XZ_id.push(row.MaterialId)
        await deleteGLWLlist(this.WL_arr)
        this.shuaxinWL()
        this.WL_arr.XZ_id = []
        this.$message({
          type: 'success',
          message: '删除成功!'
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    },
    async SY_dizhi(row) { // 关联货位
      this.XZ_xjhw_id.id = row.Id
      this.HW_list = await getGLHWlist()
      this.GL_huowei = true
      console.log(row)
    },
    async XJHW() {
      this.TJ_HW = true
      this.TJ_HW_list = await getaddGLHWlist()
      const res = await addGLHWlist()
      console.log(res)
      this.TJ_HWGL_SOUSUO = res
    },
    async GLHW_chaxun() { // 查询
      this.TJ_HW_list = await GLHW_chaxun(this.GLHW_TJ)
    },
    GLHW_xz(val) { // 关联货位选中
      this.multipleSelection = val
      if (val.length > 0) {
        for (let i = 0; i < val.length; i++) {
          if (val[i].Id !== this.XZ_xjhw_id.keys[i]) {
            this.XZ_xjhw_id.keys.push(val[i].Id)
          }
        }
      } else {
        this.XZ_xjhw_id.keys = val
      }
      console.log('XZ_xjhw_id', this.XZ_xjhw_id)
      console.log('val', val)
    },
    GLHW_chongzhi() {
      this.GLHW_TJ = {
        TypeId: '',
        Keyword: '',
        AreaName: ''
      }
    },
    GLHW_XJ_QX() {
      this.GLHW_chongzhi()
      this.TJ_HW = false
    },
    async GLHW_XJ_QD() {
      await addGLHWlist2(this.XZ_xjhw_id)
      this.GLHW_XJ_QX()
    }
  }
}
</script>
<style scoped>
.item{
  margin-left: 50px;
  margin-top: 50px;
}
.sousuo {
  padding-right: 10px;
}
</style>
